import socket
import re

server = socket.socket()
server.bind(('0.0.0.0', 8181))
server.listen(5)

client = socket.socket()

while True:
    conn, addr = server.accept()
    data = conn.recv(1024)
    print(data)
    url = re.findall(rb'Host:(.*?)\r', data)[0]
    print(url)
    client.connect((url, 80))
    client.send(data)
    while True:
        res = client.recv(1024)
        if res:
            conn.send(res)
        else:
            break
